from django.test import TestCase

# Create your tests here.
import requests

HEADERS = {
    'User-Agent':
    'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36'
}

URL_PATTERN_DICT = {'wiki':'https://%s.wikipedia.org/wiki/%s','google':'https://www.google.com.hk/search?q=%s',}

def fetchData(somewhat: str, website='wiki',languagetype='zh'):
    resultData = '<h1>oooops!</h1>'
    if website == 'wiki':
        pass #resultData = requests.get(URL_PATTERN_DICT[website] % (languagetype, somewhat),headers=HEADERS).text  #https://zh.wikipedia.org/wiki/Reddit
    elif website == 'oneurl':
        resultData = requests.get(somewhat,headers=HEADERS).text
    else:
        resultData = requests.get(URL_PATTERN_DICT[website] % somewhat,headers=HEADERS).text

    return resultData

if __name__ == "__main__":
	resultData = requests.get(URL_PATTERN_DICT['google'] % '星链',headers=HEADERS).text
	with open('C:/E/temp/pic/google.html','w') as f:
		f.write(resultData)
